package LeetCode.month01.day12;

public class No55 {
    public static void main(String[] args) {
        int[] nums = {3,0,8,2,0,0,1};
        System.out.println(canJump(nums));
    }
    public static boolean canJump(int[] nums) {
        int rightmost = 0;
        int len = nums.length;
        for (int i = 0; i < len; i++) {
            if(rightmost>=i){
                if(nums[i]+i>rightmost) rightmost = nums[i]+i;
                if (rightmost>=nums.length) return true;
            }
        }
        return false;
    }
}
